package com.mingqi.enetconnected.primary.mytask.activity;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.mingqi.enetconnected.R;
import com.mingqi.enetconnected.base.BaseActivity;
import com.mingqi.enetconnected.primary.mytask.adapter.CommonParamsAdapter;
import com.mingqi.enetconnected.view.LeftEditText;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class ChooseParamsActivity extends BaseActivity {

    @BindView(R.id.let_search)
    LeftEditText mLetSearch;
    @BindView(R.id.tv_search)
    TextView mTvSearch;
    @BindView(R.id.rv_params)
    RecyclerView mRvParams;
    private CommonParamsAdapter mCommonParamsAdapter;

    @Override
    protected int getLayoutID() {
        return R.layout.activity_choose_params;
    }

    @Override
    protected void initView() {

        setTitleName("请选择表具型号");
    }

    @Override
    protected void initData() {

        List<String> stringList = new ArrayList<>();
        for (int i = 0; i < 5; i++) {

            stringList.add("" + i);
        }
        mCommonParamsAdapter = new CommonParamsAdapter(stringList);
        mRvParams.setAdapter(mCommonParamsAdapter);
        mRvParams.setLayoutManager(new LinearLayoutManager(this));

        mCommonParamsAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {

                Toast.makeText(ChooseParamsActivity.this, "点击了" + position, Toast.LENGTH_SHORT).show();

            }
        });
    }

    @Override
    protected void initClick() {

        mTvSearch.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                String searchStr = mLetSearch.getText().toString();
                Toast.makeText(ChooseParamsActivity.this, "搜索：" + searchStr, Toast.LENGTH_SHORT).show();
                mCommonParamsAdapter.notifyDataSetChanged();
            }
        });
    }
}
